package com.wlr.study.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * 回文链表
 */
public class LeetCode234 {
    public boolean isPalindrome(ListNode head) {
        List<Integer> list = new ArrayList<>();
        while (head != null) {
            list.add(head.val);
            head = head.next;
        }
        int length = list.size();
        for (int i = 0; i < length; i++) {
            if (list.get(i) != list.get(length - 1)) {
                return false;
            }
            length--;
        }
        return true;
    }
}
